#include <stdio.h>

int main()
{
    int a[10000] = {0}, b[10000]={0};
    int n, m, i, j, k = 0;
    //输入数组一
    scanf("%d", &n);
    for (i = n - 1; i >= 0; i--)
    {
        scanf("%d", &a[i]);
    }
    //输入数组二
    scanf("%d", &m);
    for (j = 0; j < m; j++)
    {
        scanf("%d", &b[j]);
    }
    //新建数组
    int c[n + m];
    i = 0, j = 0;
    while (i < n && j < m)
    {
        if (a[i] >= b[j])
            c[k++] = a[i++];
        else
            c[k++] = b[j++]; //把a和b数组存入c中
    }

    while (i < n) //a b数组中多的数字存入
        c[k++] = a[i++];

    while (j < m)
        c[k++] = b[j++];

    for (k = 0; k < m + n - 1; k++)
        printf("%d ", c[k]);
    printf("%d", c[m + n - 1]);
    return 0;
}
